//
//  BaseNavigationController.m
//  UGoods
//
//  Created by dllo on 16/1/23.
//  Copyright © 2016年 蓝鸥科技.李贺. All rights reserved.
//

#import "BaseNavigationController.h"
#import "NightMode.h"
@implementation BaseNavigationController

- (void)dealloc
{
    // dealloc移除观察着
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController {
    self = [super initWithRootViewController:rootViewController];
    if (self) {
        
        if ([NightMode nightModeSharedInstance].isNight) {
            [self setNightDayModel];
        } else {
            [self setLightDayModel];
        }
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLightDayModel) name:@"day" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setNightDayModel) name:@"night" object:nil];
    }
    return self;
}


- (void)setLightDayModel {
    self.navigationBar.tintColor = [UIColor blackColor];
    self.navigationBar.barTintColor = [UIColor whiteColor];
    
    NSDictionary *barDic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, [UIFont boldSystemFontOfSize:15], NSFontAttributeName, nil];
    [self.navigationBar setTitleTextAttributes:barDic];

    
}

- (void)setNightDayModel {
    
    NSDictionary *barDic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont boldSystemFontOfSize:15], NSFontAttributeName, nil];
    [self.navigationBar setTitleTextAttributes:barDic];

    
    self.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationBar.barTintColor = [UIColor blackColor];
}




@end
